package com.gx.model.dto.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * @Author: lpj
 * @Date: 2021/7/1 9:45
 * 分页条件
 */
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel
public class BaseQueryDto extends BaseDto implements Serializable {

    @ApiModelProperty(value = "当前页码",example = "1")
    private Integer currPage;

    @ApiModelProperty(value = "每页显示条数",example = "10")
    private Integer pageSize;

    /**
     * 分页参数合理化校验
     */
    public void checkPageParam() {
        if (this.currPage == null || this.currPage <= 0) {
            setCurrPage(1);
        }
        if (this.pageSize == null || this.pageSize <= 0 || this.pageSize > 100) {
            setPageSize(10);
        }
    }
}
